﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 迭代器模式.Menu;

namespace 迭代器模式
{
    class Program
    {
        static void Main(string[] args)
        {
            {
                Console.WriteLine("*********KFCMenu************");
                KFCMenu menu = new KFCMenu();
                Food[] foods = menu.GetFoods();

                for (int i = 0; i < foods.Length; i++)
                {
                    Console.WriteLine($"{foods[i].Id} {foods[i].Name} {foods[i].Price}$");
                }


                IIterator<Food> foodIIterator = menu.GetIterator();

                while (foodIIterator.MoveNext())
                {
                    Food food = foodIIterator.Current;
                    Console.WriteLine($"{food.Id} {food.Name} {food.Price}$");
                }
          
            }

            {
                Console.WriteLine("*********MacDonaldMenu************");
                MacDonaldMenu menu = new MacDonaldMenu();
                var foods = menu.GetFoods();

                for (int i = 0; i < foods.Count; i++)
                {
                    Console.WriteLine($"{foods[i].Id} {foods[i].Name} {foods[i].Price}$");
                }

                IIterator<Food> foodIIterator = menu.GetIterator();

                while (foodIIterator.MoveNext())
                {
                    Food food = foodIIterator.Current;
                    Console.WriteLine($"{food.Id} {food.Name} {food.Price}$");
                }
            }
            Console.Read();
        }
    }
}
